<?php

namespace App\Http\Controllers\OA;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Logic\summaryLogic;
use Illuminate\Http\Request;

/**
 * 数据汇总
 */
class summaryController extends Controller
{
    public function getList(Request $request)
    {
        try{
            $rules = [
                'page'=>'required|numeric|in:1',
                'page_size'=>'required|numeric|in:10',
                'year'=>'sometimes|string|nullable',
                'company_id'=>'sometimes|numeric|nullable',
                'dept_id'=>'sometimes|numeric|nullable',
                'uid'=>'sometimes|numeric|nullable',
                'customer_id'=>'sometimes|numeric|nullable',
                'xmid'=>'sometimes|numeric|nullable',
            ];
            $this->verify($request->all(),$rules);
            $list = (new summaryLogic())->getList($request->all());
            ret_json('ok','ok',$list);

        }catch (\Exception $e){
            ret_json('err',$e->getMessage());
        }
    }

    //获取汇总详情数据
    public function getSummaryDetail(Request $request)
    {
        try{
            //dd(11);
            $rules = ['xmid'=>'required|exists:project_lx,id'];
            $this->verify($request->all(),$rules);
            $detail = (new summaryLogic())->getSummaryDetail($request->all());
            ret_json('ok','ok',$detail);
        }catch (\Exception $e){
           ret_json('err',$e->getMessage());
        }
    }
}
